home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 002a / be310.zip / BIOS_INT.CHS < prev    next >
Text File  |  1993-06-01  |  2KB  |  45 lines

  1. /* CHESS FUNCTION(S): getkeyval, wait_press
  2. /*              DATE: 3/1/93
  3. /*            AUTHOR: C. Schanck
  4. /*
  5. /*       DESCRIPTION:    
  6. /* getkeyval:
  7. /* this routine will wait for a keystroke and return one of three 
  8. /* things, depending on the parameter 'type'.  
  9. /*    type = 0          return 16-bit scancode+ascii value
  10. /*    type = 1          return 8-bit scancode
  11. /*    type = 2          return 8-bit ascii value
  12. /*
  13. /* wait_press:
  14. /* this routine waits until a key is pressed, but does not
  15. /* process the keystroke.
  16. /*
  17. /* These routines illustrate the use of Bingo's BIOS interface.
  18. getkeyval
  19. int type
  20. {
  21.    clear_regs();        /* clear the registers out 
  22.    set_reg("ah",0);     /* set AH to 0 for service 0
  23.    gen_interrupt(22);   /* generate interupt 22 (16 hex)
  24.    if(type==0)       
  25.       return(get_reg("ax"));  /* type 0 returns AX (scancode+ascii value)
  26.    else if(type==1)
  27.       return(get_reg("ah"));  /* type 1 returns AH (scancode)
  28.    else if(type==2)
  29.       return(get_reg("al"));  /* type 2 returns AL (ascii value)
  30. }
  31. /* this will wait until a key is pressed, but it will not 
  32. /* actually process the key.
  33. wait_press
  34. {
  35.    int ok;
  36.    ok=0;
  37.    while(ok==0){
  38.       clear_regs();           /* clear the registers out 
  39.       set_reg("ah",1);        /* set AH to 1 for service 1
  40.       gen_interrupt(22);      /* generate interupt 22 (16 hex) (keyboard)
  41.       ok=get_reg("flags");    /* get the flags
  42.       ok=(ok%128)<64;         /* check if bit 7 is clear
  43.    }
  44. }
  45.